﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;
using RMS.Utils.Dicom.Commen;
using RMS.Utils.Dicom;

namespace RMS.Utils.Dicom.DataStructure
{
    public class Tag
    {
        #region [Properties]
        private string _tagName = null;
        public string TagName
        {
            get
            {
                return _tagName;
            }
        }
        public bool IsUserDefine
        {
            get
            {
                if (DicomDictionary.TagDiscription(this._tagName) != null)
                    return false;
                else
                    return true;
            }
        }
        public String TagDiscription
        {
            get
            {
                return DicomDictionary.TagDiscription(this._tagName);
            }
        }
        #endregion
        #region [Constructor]
        public Tag()
        {
            ReaaTag();
        }
        #endregion
        #region [Helper Method
        protected void ReaaTag()
        {
            SetInt(StreamFile.Read(Constants.TageByteLenght).ToUInt16(), StreamFile.Read(Constants.TageByteLenght).ToUInt16());
        }
        private void SetInt(uint group, uint element)
        {
            if (group < 0x0000 || group > 0xFFFF)
                throw new ArgumentOutOfRangeException("Tag.Group");
            if (element < 0x0000 || element > 0xFFFF)
                throw new ArgumentOutOfRangeException("Tag.Element");
            _tagName = string.Format("({0},{1})", (string)group.ToHex(), (string)element.ToHex());
            if (_tagName == Constants.PixelDataTag)
            {
                StreamFile.IsPixelData = true;
            }
        }
        #endregion
    }
}


























